package com.atguigu.day17_1.test04;

import sun.reflect.generics.tree.Tree;

import java.util.*;

/**
 * @author fenge
 */
public class Test04 {
    public static void main(String[] args) {
        String[] nums = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        String[] colors = {"方片", "梅花", "红桃", "黑桃"};
        HashMap<Integer, String> hashMap = new HashMap<>();
        int count = 1;
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < colors.length; j++) {
                hashMap.put(count++, colors[j] + nums[i]);
            }
        }
        hashMap.put(count++, "小王");
        hashMap.put(count++, "大王");
        System.out.println(hashMap);
        ArrayList<Integer> arrayList = new ArrayList<>();
        Set<Map.Entry<Integer, String>> entries = hashMap.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            arrayList.add(entry.getKey());
        }
        /*for (Integer integer : arrayList) {
            System.out.println(integer);
        }*/
        Collections.shuffle(arrayList);
        /*for (Integer integer : arrayList) {
            System.out.println(integer);
        }*/
        TreeSet<Integer> treeSet1 = new TreeSet<>();
        TreeSet<Integer> treeSet2 = new TreeSet<>();
        TreeSet<Integer> treeSet3 = new TreeSet<>();
        TreeSet<Integer> treeSet4 = new TreeSet<>();
        for (int i = 0; i < arrayList.size() - 2; ) {
//            arrayList.remove(arrayList.get(i));
            treeSet1.add(arrayList.get(i++));
//            arrayList.remove(arrayList.get(i));
            treeSet2.add(arrayList.get(i++));
//            arrayList.remove(arrayList.get(i));
            treeSet3.add(arrayList.get(i++));
//            arrayList.remove(arrayList.get(i));
            treeSet4.add(arrayList.get(i++));
        }
        /*System.out.println(treeSet1);
        System.out.println(treeSet2);
        System.out.println(treeSet3);
        System.out.println(treeSet4);*/
        for (Map.Entry<Integer, String> entry : entries) {
            for (Integer integer : treeSet1) {
                if (integer == entry.getKey()) {
                    arrayList.remove(integer);
                    System.out.print(entry + " ");
                }
            }
        }
        System.out.println();
        for (Map.Entry<Integer, String> entry : entries) {
            for (Integer integer : treeSet2) {
                if (integer == entry.getKey()) {
                    arrayList.remove(integer);
                    System.out.print(entry + " ");
                }
            }
        }
        System.out.println();
        for (Map.Entry<Integer, String> entry : entries) {
            for (Integer integer : treeSet3) {
                if (integer == entry.getKey()) {
                    arrayList.remove(integer);
                    System.out.print(entry + " ");
                }
            }
        }
        System.out.println();
        for (Map.Entry<Integer, String> entry : entries) {
            for (Integer integer : treeSet4) {
                if (integer == entry.getKey()) {
                    arrayList.remove(integer);
                    System.out.print(entry + " ");
                }
            }
        }
        System.out.println();
        for (Map.Entry<Integer, String> entry : entries) {
            for (Integer integer : arrayList) {
                if (integer == entry.getKey())
                    System.out.print(entry + " ");
            }
        }
//        System.out.println(hashMap);
    }
}
